#include <iostream>
using namespace std;
int main()
{
	int n = 0;
	cin >> n;
	if (n <= 2)
		cout << -1;
	else if (n % 4 == 1 || n % 4 == 3)
		cout << 2;
	else if (n % 4 == 2)
		cout << 4;
	else
		cout << 3;
	return 0;
}